<?php
define('MYSQL_WHERE_SYMBOL', 'symbol');
define('NO_SYMBOL', 'nos');

class Home_Model_Base extends model {
    //行业
    public $_industry = array(
        0   => '不限',
        1   => '金融服务/投资',
        2   => '房地产',
        3   => '能源',
        4   => '化学化工',
        5   => '节能环保',
        6   => '建筑建材',
        7   => '矿产/钢铁/冶金',
        8   => '基础设施',
        9   => '农林牧渔',
        10  => '国防军工',
        11  => '航空航天',
        12  => '电气设备',
        13  => '机械机电',
        14  => '交通运输/仓储物流',
        15  => '汽车/汽配',
        16  => '纺织/服装/饰品',
        17  => '旅游酒店',
        18  => '餐饮/休闲/娱乐',
        19  => '教育/培训/体育',
        20  => '文化/传媒/广告',
        21  => '批发零售',
        22  => '食品/饮料/烟草',
        23  => '家居日用',
        24  => '医疗保健',
        25  => '生物医药',
        26  => 'IT互联网',
        27  => '电子/通信',
        28  => '海洋利用与开发',
        29  => '商务贸易',
        30  => '家政服务',
        31  => '园林园艺',
        32  => '珠宝/收藏/奢侈品',
        33  => '政府/事业单位',
        34  => '其他行业'
    );

    public $_area = array(
        '0' => '不限',
        '1' => '北京',
        '2' => '上海',
        '3' => '广州',
        '4' => '深圳',
        '5' => '成都',
        '6' => '宁波',
    );

    //融资金额区间
    public $_financing = array(
        '0' => array('title'=>'不限', MYSQL_WHERE_SYMBOL=>' 1=1 '),
        '1' => array('title'=>'10万以下', MYSQL_WHERE_SYMBOL=>' < 100000 '),
        '2' => array('title'=>'10万~50万', MYSQL_WHERE_SYMBOL=>' between 100000 and 499999 '),
        '3' => array('title'=>'50万~100万', MYSQL_WHERE_SYMBOL=>' between 500000 and 999999 '),
        '4' => array('title'=>'100万~500万', MYSQL_WHERE_SYMBOL=>' between 1000000 and 4999999 '),
        '5' => array('title'=>'500万~2000万', MYSQL_WHERE_SYMBOL=>' between 5000000 and 19999999 '),
        '6' => array('title'=>'2000万~5000万', MYSQL_WHERE_SYMBOL=>' between 20000000 and 49999999 '),
        '7' => array('title'=>'5000万~1亿', MYSQL_WHERE_SYMBOL=>' between 50000000 and 100000000 '),
        '8' => array('title'=>'1亿以上', MYSQL_WHERE_SYMBOL=>' > 100000000 ')
    );

    protected function _where($where, & $whereKeyValue){
        $_whereContainer = array();
        foreach ($where as $key => $value_arr) {
            if($value_arr[MYSQL_WHERE_SYMBOL] == 'like'){
                $_whereContainer[] = $key.' '.$value_arr[MYSQL_WHERE_SYMBOL].' [@'.$key.']';
            }elseif($value_arr[MYSQL_WHERE_SYMBOL] == NO_SYMBOL){
                $_whereContainer[] = $key.' '.$value_arr['value'];
            }else{
                $_whereContainer[] = $key.$value_arr[MYSQL_WHERE_SYMBOL].'[@'.$key.']';
            }
            $whereKeyValue[$key] = $value_arr['value'];
        }
        return ' WHERE '.implode(' AND ',$_whereContainer);
    }
}